import { IPSModelSortable } from '../../ipsmodel-sortable';
import { IPSAppDEUILogic } from '../../app/dataentity/ipsapp-deuilogic';
import { IPSDEUILogic } from './ipsdeuilogic';
import { IPSDEUILogicNode } from './ipsdeuilogic-node';
import { IPSDEUILogicParam } from './ipsdeuilogic-param';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEUILogicImpl extends PSModelObjectImpl implements IPSDEUILogic, IPSAppDEUILogic, IPSModelSortable {
  get codeName(): string {
    return this.M.codeName;
  }

  get defaultParamName(): string {
    return this.M.defaultParamName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected psdeuilogicnodes: IPSDEUILogicNode[] | null = null;

  getPSDEUILogicNodes(): IPSDEUILogicNode[] | null {
    if (this.psdeuilogicnodes == null) {
      this.psdeuilogicnodes = this.fillChildListModel(this.M.getPSDEUILogicNodes, 'dataentity.logic.IPSDEUILogicNode') as IPSDEUILogicNode[];
    }
    return this.psdeuilogicnodes;
  }

  get psDEUILogicNodes(): IPSDEUILogicNode[] | null {
    return this.getPSDEUILogicNodes();
  }

  findPSDEUILogicNode(objKey: any): IPSDEUILogicNode | null {
    return this.getPSModel5('dataentity.logic.IPSDEUILogicNode', this.getPSDEUILogicNodes(), objKey) as IPSDEUILogicNode;
  }

  protected psdeuilogicparams: IPSDEUILogicParam[] | null = null;

  getPSDEUILogicParams(): IPSDEUILogicParam[] | null {
    if (this.psdeuilogicparams == null) {
      this.psdeuilogicparams = this.fillChildListModel(this.M.getPSDEUILogicParams, 'dataentity.logic.IPSDEUILogicParam') as IPSDEUILogicParam[];
    }
    return this.psdeuilogicparams;
  }

  get psDEUILogicParams(): IPSDEUILogicParam[] | null {
    return this.getPSDEUILogicParams();
  }

  findPSDEUILogicParam(objKey: any): IPSDEUILogicParam | null {
    return this.getPSModel5('dataentity.logic.IPSDEUILogicParam', this.getPSDEUILogicParams(), objKey) as IPSDEUILogicParam;
  }

  protected startpsdeuilogicnode: IPSDEUILogicNode | null = null;

  getStartPSDEUILogicNode(): IPSDEUILogicNode | null {
    if (this.startpsdeuilogicnode != null) return this.startpsdeuilogicnode;
    const value = this.M.getStartPSDEUILogicNode;
    if (value == null) {
      return null;
    }
    this.startpsdeuilogicnode = this.findPSDEUILogicNode(value);
    return this.startpsdeuilogicnode;
  }

  get startPSDEUILogicNode(): IPSDEUILogicNode | null {
    return this.getStartPSDEUILogicNode();
  }

  getStartPSDEUILogicNodeMust(): IPSDEUILogicNode {
    const value = this.getStartPSDEUILogicNode();
    if (value == null) {
      throw new Error('未指定开始处理节点');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSDEUILogicImpl';
  }

  instanceof(cls: string): boolean {
    if (
      cls == 'IPSModelSortable' ||
      cls == 'app.IPSApplicationObject' ||
      cls == 'app.dataentity.IPSAppDEUILogic' ||
      cls == 'app.dataentity.IPSAppDataEntityObject' ||
      cls == 'dataentity.logic.IPSDEUILogic'
    )
      return true;
    return super.instanceof(cls);
  }
}
